class Task34:
    def run(self, tree, n):
        result = []
        if tree is None:
            return result
        self.run_inner(tree, result, [], 0, n)
        return result

    def run_inner(self, node, result, path, sum, n):
        sum += node.val
        path.append(node.val)
        if self.is_leaf(node):
            if sum == n:
                result.append(path + [])
        else:
            if node.left is not None:
                self.run_inner(node.left, result, path, sum, n)
            if node.right is not None:
                self.run_inner(node.right, result, path, sum, n)
        path.pop()

    def is_leaf(self, node):
        return node.left is None and node.right is None
